import request from '@/utils/request';

/**
 * 创建订单
 * @param {Object} data - 订单信息
 * @returns {Promise}
 */
export function createOrder(data) {
  return request({
    url: '/order/create',
    method: 'post',
    data
  });
}

/**
 * 完成订单
 * @param {number} id - 订单ID
 * @returns {Promise}
 */
export function completeOrder(id) {
  return request({
    url: `/order/complete/${id}`,
    method: 'put'
  });
}

/**
 * 取消订单
 * @param {number} id - 订单ID
 * @returns {Promise}
 */
export function cancelOrder(id) {
  return request({
    url: `/order/cancel/${id}`,
    method: 'delete'
  });
}

/**
 * 查询用户订单列表
 * @param {number} userId - 用户ID
 * @param {Object} params - 分页参数
 * @returns {Promise}
 */
export function getUserOrders(userId, params) {
  return request({
    url: `/order/user/${userId}`,
    method: 'get',
    params
  });
}

/**
 * 查询车行订单列表
 * @param {number} shopId - 车行ID
 * @param {Object} params - 分页参数
 * @returns {Promise}
 */
export function getShopOrders(shopId, params) {
  return request({
    url: `/order/shop/${shopId}`,
    method: 'get',
    params
  });
}

/**
 * 获取订单详情
 * @param {number} id - 订单ID
 * @returns {Promise}
 */
export function getOrderDetail(id) {
  return request({
    url: `/order/${id}`,
    method: 'get'
  });
}
